﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using System.IO;
using Apex.Networking.Common;

namespace Apex.Networking.Server
{
    public delegate void NetEventHandler(byte[] data = null);
    public delegate void NetRetryHandler(int retryNumber);

    public class AsyncServer : IServer
    {
        public List<IController> RouteControllers { get; set; }
        public ServerConfiguration Configuration { get; set; }

        public AsyncServer()
        {
            RouteControllers = new List<IController>();
        }

        private Action<PacketBase> GetCallback(string route)
        {
            Action<PacketBase> rval = null;

            foreach (var x in RouteControllers)
            {
                if (rval != null)
                    throw new InvalidOperationException("Multiple appearences of the same route detected");

                rval = x.GetRouteCallback(route);
            }

            return rval;
        }

        #region Server Workflow

        public int OnStart()
        {
            throw new NotImplementedException();
        }

        public int OnAccept()
        {
            throw new NotImplementedException();
        }

        public int OnReceive()
        {
            throw new NotImplementedException();
        }

        public int OnDissconnect()
        {
            throw new NotImplementedException();
        }
        #endregion

        #region Server Control

        public void StartServer()
        {
            throw new NotImplementedException();
        }

        public void StartServer(ServerConfiguration configuration)
        {
            throw new NotImplementedException();
        }

        #endregion

    }
}
